//
//  TTDatabaseResult.m
//  Tint
//
//  Created by Kevin Wu on 2/28/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTDatabaseResult.h"
#import "TTDatabaseRow.h"


@implementation TTDatabaseResult


#pragma mark - Accessors

@synthesize errorCode = _errorCode;
@synthesize errorMessage = _errorMessage;
@synthesize columnNames = _columnNames;
@synthesize columnTypes = _columnTypes;
@synthesize rows = _rows;


#pragma mark - Memory

- (id)init {
	if((self = [super init])) {
		_errorCode = 0;
		_columnNames = [[NSMutableArray alloc] init];
		_columnTypes = [[NSMutableArray alloc] init];
		_rows = [[NSMutableArray alloc] init];
	}
	
	return self;
}

- (void)dealloc {
    TTRelease(_errorMessage);
    TTRelease(_columnNames);
    TTRelease(_columnTypes);
    TTRelease(_rows);
	[super dealloc];
}



#pragma mark - Public

- (void)addRow:(TTDatabaseRow *)row {
	[_rows addObjectIfNotNil:row];
}

- (TTDatabaseRow *)rowAtIndex:(NSInteger)index {
    return [_rows objectOrNilAtIndex:index];
}

- (NSUInteger)count {
    return [_rows count];
}

@end
